import { useSelector, useDispatch } from "react-redux"
import { increment, decrement, asyncIncrement } from "./store/countSlice";

export default function ReduxToolkit(){
    return (
        <div>
            <A/>
        </div>
    )
}
function A(){
    const {count} = useSelector(state => state.value)
    const dispatch = useDispatch()
    return (
        <div>
            count:{count}
            <br/>
            <button onClick={() => dispatch(increment(1))}>+1</button>
            <button onClick={() => dispatch(decrement(1))}>-1</button>
            <button onClick={() => dispatch(asyncIncrement({type: 'fail'}))}>+1 Async</button>
        </div>
    )
}